Vue.component('v-chart', VueECharts)
new Vue({
    el: '#app',
    data() {
        return {
            isReady: false, //数据是否已经准备好,防止页面闪现大括号{{}}
            stat1: {
                fiveYearAmount: 33336059, //五年来上市数量（支）
                currentYearAmount: 10000012 //当年上市数量（支）
            },
            stat2: {
                chartOption: {},
                tipInfo: { //提示框
                    data: {
                        name: '',
                        value:'',
                        otherValue: {
                            xl: 0,
                            ycfyfss: 0,
                            ycfyfsl: '0%'
                        }
                    },
                    position: {
                        x: '-',
                        y: '-'
                    }

                }
            }
        }

    },
    computed: {
        fiveYearAmountStrs() {
            return Array.from(this.formatNum(this.stat1.fiveYearAmount))
        },
        currentYearAmountStrs() {
            return Array.from(this.formatNum(this.stat1.currentYearAmount))
        }
    },
    created() {
        setTimeout(() => {
            this.isReady = true
        }, 200)
        this.createStat1()
        this.createStat2()
    },
    methods: {
        formatNum(num) { //格式化数字为字符串数组
            var num = (num || 0).toString();
            var result = '';
            while (num.length > 3) {
                result = ',' + num.slice(-3) + result;
                num = num.slice(0, num.length - 3);
            }
            if (num) { result = num + result; }
            return result;
        },
        createStat1() { //获取上市数量

        },
        createStat2() {
            var dataList = [
                [{ name: '浙江省' }, { name: '内蒙古自治区', value: { xl: 65231, ycfyfss: 10, ycfyfsl: '0.015%' } }],
                [{ name: '浙江省' }, { name: '北京市', value: { xl: 65330, ycfyfss: 110, ycfyfsl: '0.015%' } }],
                [{ name: '浙江省' }, { name: '四川省', value: { xl: 65235, ycfyfss: 140, ycfyfsl: '0.015%' } }],
                [{ name: '浙江省' }, { name: '天津市', value: { xl: 65236, ycfyfss: 130, ycfyfsl: '0.015%' } }],
                [{ name: '浙江省' }, { name: '安徽省', value: { xl: 87992, ycfyfss: 130, ycfyfsl: '0.015%' } }],
                [{ name: '浙江省' }, { name: '山东省', value: { xl: 62642, ycfyfss: 10, ycfyfsl: '0.015%' } }],
                [{ name: '浙江省' }, { name: '黑龙江省', value: { xl: 88983, ycfyfss: 10, ycfyfsl: '0.015%' } }],
                [{ name: '浙江省' }, { name: '广东省', value: { xl: 3234, ycfyfss: 10, ycfyfsl: '0.015%' } }],
                [{ name: '浙江省' }, { name: '青海省', value: { xl: 4355, ycfyfss: 10, ycfyfsl: '0.015%' } }],
                [{ name: '浙江省' }, { name: '湖北省', value: { xl: 5566, ycfyfss: 10, ycfyfsl: '0.015%' } }]
            ];
            var that = this;
            $.get('/src/js/china.json', function(mapJson) {
                that.stat2.chartOption = AllOptions.createOption2(mapJson, dataList)
            })

        },
        hoverMap(item) {
            this.stat2.tipInfo = {
                data: item.data,
                position: {
                    x: item.event.offsetX,
                    y: item.event.offsetY
                }
            }
        },
        submitForm() {

        },
        exportForm() {

        }

    }
})